
#ifndef ATOM_H
#define ATOM_H

#include <string.h>
#include <fstream.h>
#include "global.h"

using std::string;

 /*! \file */
 //! This class provides abstraction to an atom object.

 /*! An atom is described as an object with a label and xyz cartesian coordinate. */


class atom {
	//! This friend function output the info of the atom <anAtom> into an output stream <out>.
        /*!
                 \param out an output stream.
                 \param anAtom an atom which info is to be printed out.
        */
	friend ostream& operator<<( ostream& out, const atom& anAtom);	

	public:
		double x,y,z;
		char label;
		
		 /*! \brief constructor */
		atom();

		//! This constructor generates this atom with the input values.
                /*!
                        \param aLabel label of the atom.
                        \param a x-coordinate of the atom.
                        \param b y-coordinate of the atom.
                        \param c z-coordinate of the atom.
                */
		atom( char aLabel, double a, double b, double c );

		//! This copy constructor generates this atom with another atom's values.
                /*!
                        \param rhs another atom to be copied.
                */
		atom( const atom& rhs );

		 /*! \brief destructor */
		~atom();

		//! This function calculates the distance of this atom to another atom <rhs>.
                /*!
                        \param rhs another atom, to which distance is to be calculated.
                */
		double getDistanceTo( atom& rhs );
		
		//! Assignment(=) operator.
                /*!
                        \param rhs another atom to be assigned to this atom.
                */
		atom& operator=( const atom &rhs );
		
		//! Addition(+) operator. This operator adds up the coordinates of this atom with another atom <rhs>.
                /*!
                        \param rhs another atom, which values is to be added to this atom.
                */
		atom& operator+( atom &rhs );

		//! Addition and assignment(+=) operator. This operator adds up the coordinates of this atom with another atom <rhs>.
                /*!
                        \param rhs another atom, which values is to be added to this atom.
                */
		atom& operator+=( atom &rhs );

		//! Index([]) operator. This operator return coordinate of index i of this atom.
                /*!
                        \param index index of coordinate( 0 for x, 1 for y, 2 for z ).
                */
		double operator[]( int index );

		//! Subtraction(-) operator. This operator subtracts the coordinates of this atom with another atom <rhs>.
                /*!
                        \param rhs another atom, which values is to be subtracted from this atom.
                */
		atom& operator-( atom &rhs );

		//! Subtraction & assignment(-=) operator. This operator subtracts the coordinates of this atom with another atom <rhs>.
                /*!
                        \param rhs another atom, which values is to be subtracted from this atom.
                */
		atom& operator-=( atom &rhs );
		
		//! This function sets the value for a particular coordinate.
                /*!
                        \param index index of coordinate( 0 for x, 1 for y, 2 for z ).
                        \param val value to be put in coordinate <index>.
                */
		void setAt( int index, double val );		

		//! This function prints the content of this atom to file output stream <out>.
                /*!
                        \param out file output stream.
                */
		void printToFileStream( ofstream& out );

};

#endif

